From: Ansuel Smith Date: Thu, 16 Jan 2020 14:16:09 +0000 (+0100) Subject: luci-base: make rpc webserver path configurable X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22http:/www.crowdsec.net/%22/%22https:/collectd.org/%22http:/www.crowdsec.net/%22?a=commitdiff_plain;h=14a81ccb63941efc0e563bfe629e94dc80af63c7;p=project%2Fluci.git luci-base: make rpc webserver path configurable Currently the ubus path that provide the webserver is hardcoded to be /ubus. Change this to make it configurable from the luci config file. Signed-off-by: Ansuel Smith (backported from commit 529bde44081d0bc07a064e9dfb1f0b3f35e61061) --- diff --git a/modules/luci-base/htdocs/luci-static/resources/luci.js b/modules/luci-base/htdocs/luci-static/resources/luci.js index d890b3a78c..6c9bec8b62 100644 --- a/modules/luci-base/htdocs/luci-static/resources/luci.js +++ b/modules/luci-base/htdocs/luci-static/resources/luci.js @@ -2536,8 +2536,8 @@ if (rpcBaseURL == null) { var rpcFallbackURL = this.url('admin/ubus'); - rpcBaseURL = Request.get('/ubus/').then(function(res) { - return (rpcBaseURL = (res.status == 400) ? '/ubus/' : rpcFallbackURL); + rpcBaseURL = Request.get(this.env.ubuspath).then(function(res) { + return (rpcBaseURL = (res.status == 400) ? L.env.ubuspath : rpcFallbackURL); }, function() { return (rpcBaseURL = rpcFallbackURL); }).then(function(url) { diff --git a/modules/luci-base/luasrc/view/header.htm b/modules/luci-base/luasrc/view/header.htm index 387c76f8f8..f0f69f2003 100644 --- a/modules/luci-base/luasrc/view/header.htm +++ b/modules/luci-base/luasrc/view/header.htm @@ -26,6 +26,7 @@ requestpath = luci.dispatcher.context.requestpath, dispatchpath = luci.dispatcher.context.path, pollinterval = luci.config.main.pollinterval or 5, + ubuspath = luci.config.main.ubuspath or '/ubus', sessionid = luci.dispatcher.context.authsession, apply_rollback = math.max(applyconf and applyconf.rollback or 30, 30), apply_holdoff = math.max(applyconf and applyconf.holdoff or 4, 1), diff --git a/modules/luci-base/root/etc/config/luci b/modules/luci-base/root/etc/config/luci index c0f2599cc1..daa4a5b7c9 100644 --- a/modules/luci-base/root/etc/config/luci +++ b/modules/luci-base/root/etc/config/luci @@ -2,6 +2,7 @@ config core main option lang auto option mediaurlbase /luci-static/bootstrap option resourcebase /luci-static/resources + option ubuspath /ubus config extern flash_keep option uci "/etc/config/"